import javax.swing.*;
import java.util.Scanner;
public class Test6 {
    public static void main(String[] args) {
        int n = 0;
        Scanner sc = new Scanner(System.in);
        n = sc.nextInt();
        int count = 0;
        int tmp=n;
        while (tmp != 0) {
            count++;
            tmp/=10;
        }
        int ret = fun(n,count);
        System.out.println(ret);
    }
    public static int fun(int n, int count){
        int []arr = new int[count];
        int i=arr.length-1;
        while(n!=0){
            arr[i--]=n%10;
            n/=10;
        }
        for ( int j = 0;j <count; j++) {
            arr[j]+=5;
            arr[j]%=10;
        }
        int left=0;
        int right=count-1;
       while(left<right){
           int tmp=arr[left];
           arr[left]=arr[right];
           arr[right]=tmp;
           left++;
           right--;
       }
       int number=0;
        for (int k = 0; k < count; k++) {
            number=number*10+arr[k];
        }
        return number;
    }
}
